<?php 

class Event_ForeignCouponForm extends Crud_Event_Handler
{
	protected $_type = 'form';
	
	/**
	 * Run handler with options array.
	 * 
	 * @param ForeignCouponRow $row
	 * @return void
	 */
	public function run($form)
	{
		$element = $form->getElement('template');

		$this->_attrticket($form);
		$this->_attrproduct($form);

		$decoratorScript = new Zend_Form_Decorator_ViewScript();
		$decoratorScript->setViewScript('foreign-coupon/form.phtml');
		$form->setDecorators(array(
			new Zend_Form_Decorator_PrepareElements(),
			$decoratorScript,
		));
		
	}

	protected function _attrticket($form) {
		$e = new Zend_Form_Element('attendant_ticket');

		$decoratorScript = new Zend_Form_Decorator_ViewScript();
		$decoratorScript->setViewScript('foreign-coupon/element_attendant_code.phtml');
		$e->setDecorators(array(
			new Zend_Form_Decorator_PrepareElements(),
			$decoratorScript,
		));

		$form->addElement($e);
	}


	protected function _attrproduct($form) {
		$e = new Zend_Form_Element('attendant_product');

		$decoratorScript = new Zend_Form_Decorator_ViewScript();
		$decoratorScript->setViewScript('foreign-coupon/element_attendant_product.phtml');
		$e->setDecorators(array(
			new Zend_Form_Decorator_PrepareElements(),
			$decoratorScript,
		));

		$form->addElement($e);
	}
}